Skip to content

Unified display info#65

Merged
ChrisPenner merged 2 commits into
mainfrom
cp/unified-display-info
May 8, 2025
Merged

Unified display info#65
ChrisPenner merged 2 commits into
mainfrom
cp/unified-display-info

Conversation

@ChrisPenner

@ChrisPenner ChrisPenner commented May 8, 2025

Copy link
Copy Markdown
Member

Overview

Users, Orgs, and teams all need to be displayed to end-users from various API requests, but up until now have often used different representations for each different place or kind.

This tries to unify them a bit by having a Unified Display Info type which we can attach to api results where needed.

When embedded in another object it will now likely be at the displayInfo key, which is an object with a kind and payload; the kind is currently one of user org or team (though team isn't used yet).

Sometimes having the display info embedded means there's some duplicate info in the response, but at least it's more consistent this way.

E.g. here's the displayInfo key of the /account response:

    "displayInfo": {
      "info": {
        "avatarUrl": "https://avatars.githubusercontent.com/u/0?v=4",
        "handle": "localgithubuser",
        "name": "Local Github User",
        "userId": "U-<UUID>"
      },
      "kind": "user"
    },

If that user is an org it'll look like this:

      "displayInfo": {
        "info": {
          "isCommercial": false,
          "orgId": "ORG-<UUID>",
          "user": {
            "avatarUrl": "https://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50?f=y&d=retro",
            "handle": "unison",
            "name": "Unison Org",
            "userId": "U-<UUID>"
          }
        },
        "kind": "org"
      },

Note that the org has its own info, as well as a user display info embedded within it.

Search results can return projects OR a UserLike, if the tag is UserLike then there'll be one of these display info's inside:

E.g. here's a search response:

[
    {
      "displayInfo": {
        "info": {
          "avatarUrl": null,
          "handle": "test",
          "name": null,
          "userId": "U-<UUID>"
        },
        "kind": "user"
      },
      "tag": "UserLike"
    },
    {
      "projectRef": "@test/publictestproject",
      "summary": "test project summary",
      "tag": "Project",
      "visibility": "public"
    }
  ]

Test coverage

See transcripts

@ChrisPenner ChrisPenner merged commit 0b43512 into main May 8, 2025
4 checks passed
@ChrisPenner ChrisPenner deleted the cp/unified-display-info branch May 8, 2025 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant